package io.renren.modules.workmanagement.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.sys.controller.AbstractController;
import io.renren.modules.workmanagement.entity.WorkAnswerEntity;
import io.renren.modules.workmanagement.service.WorkAnswerService;
import io.renren.modules.workmanagement.vo.FillAnswerVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 *
 *
 * @author yewei
 * @email sunlightcs@gmail.com
 * @date 2022-04-28 00:25:04
 */
@RestController
@RequestMapping("workmanagement/workanswer")
public class WorkAnswerController extends AbstractController {
    @Autowired
    private WorkAnswerService workAnswerService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = workAnswerService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		WorkAnswerEntity workAnswer = workAnswerService.getById(id);

        return R.ok().put("workAnswer", workAnswer);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody WorkAnswerEntity workAnswer){
		workAnswerService.save(workAnswer);

        return R.ok();
    }
    /**
     * 保存
     */
    @PostMapping("/fillAnswer")
    public R fillAnswer(@RequestBody FillAnswerVO fillAnswerVO){
        workAnswerService.fillAnswer(fillAnswerVO,getUserId());

        return R.ok();
    }
    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody WorkAnswerEntity workAnswer){
		workAnswerService.updateById(workAnswer);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		workAnswerService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }


}
